package com.atguigu.tingshu.album.client;

import com.atguigu.tingshu.album.service.AlbumInfoService;
import com.atguigu.tingshu.common.cache.GuiGuCache;
import com.atguigu.tingshu.common.constant.RedisConstant;
import com.atguigu.tingshu.model.album.AlbumAttributeValue;
import com.atguigu.tingshu.model.album.AlbumInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 专辑信息供内部调用的控制层
 *
 * @author Taeyang
 * @date 2025/4/28
 */
@RestController
@RequestMapping("/client/album/albumInfo")
public class AlbumClientController {
    private final AlbumInfoService albumInfoService;

    @Autowired
    public AlbumClientController(AlbumInfoService albumInfoService) {
        this.albumInfoService = albumInfoService;
    }

    /**
     * 根据id查询专辑的详细信息
     *
     * @param albumId
     * @return
     */
    @GuiGuCache(prefix = RedisConstant.ALBUM_INFO_PREFIX, inBloom = true)
    @GetMapping("/getAlbumInfoById/{albumId}")
    public AlbumInfo getAlbumInfoById(@PathVariable("albumId") Long albumId) {
        return albumInfoService.getById(albumId);
    }

    /**
     * 查询专辑的统计数据
     *
     * @param id
     * @return
     */
    @GuiGuCache(prefix = "getAlbumStat:")
    @GetMapping("/getAlbumStat/{id}")
    public Map<String, Object> getAlbumStat(@PathVariable("id") Long id) {
        return albumInfoService.getAlbumStat(id);
    }

    /**
     * 查询专辑的标签属性列表
     *
     * @param id
     * @return
     */
    @GuiGuCache(prefix = "getAlbumAttributeValueList:")
    @GetMapping("/getAlbumAttributeValueList/{id}")
    public List<AlbumAttributeValue> getAlbumAttributeValueList(@PathVariable("id") Long id) {
        return albumInfoService.getAlbumAttributeValueList(id);
    }

}
